function btn_share_click(url){
    var height = document.body.scrollHeight;
    var width = document.body.scrollWidth;
    $("body").append("<div id=\"shraw\" class=\"opacity\" style=\"background:gray;position:absolute;left:0; top:0;width:"+width+"px;height:"+height+"px\"></div>");
		
    $("#myshare").load(url,"",function(data){
			
	if(data==0){
            alert("请登录");$("#shraw").remove(); return;
        }		
        var myshare = $("#myshare");
        myshare.css("left",width/2-890/2+"px");
        //初始化3个搜索下拉框
        SearchItems.init({
            searchBrand:{
                panelConf:{
                    top:42,
                    left:62,
                    width:520,
                    height:400,
                    headClass:"abc_index",
                    head:'<div class="abc_index" id="abcIndex">拼音索引》<span index="A"><a href="#">A</a></span><span index="B"><a href="#">B</a></span><span index="C"><a>C</a></span><span index="D"><a>D</a></span><span index="E"><a>E</a></span><span index="F"><a>F</a></span> <span index="G"><a>G</a></span><span index="H"><a>H</a></span><span index="I"><a>I</a></span><span index="J"><a>J</a></span><span index="K"><a>K</a></span><span index="L"><a>L</a></span><span index="M"><a>M</a></span><span index="N"><a>N</a></span><span index="O"><a>O</a></span><span index="P"><a>P</a></span><span index="Q"><a>Q</a></span><span index="R"><a>R</a></span><span index="S"><a>S</a></span><span index="T"><a>T</a></span><span index="U"><a>U</a></span><span index="V"><a>V</a></span><span index="W"><a>W</a></span><span index="X"><a>X</a></span><span index="Y"><a>Y</a></span><span index="Z"><a>Z</a></span></div>',
                    result:'<div class="search_history" id="searchHistory">搜索历史：<div class="search_history_close" id="closeHistory" title="关闭搜索历史，重新搜索"></div></div><div class="brand_list" id="brandList"></div>',
                    resultWidth:96
                },
                panelEvent:function(panel){
                    ABCIndex(panel);
                }
            },
            searchCategory:{
                panelConf:{
                    top:42,
                    left:$.browser.msie?265:238,
                    width:300,
                    height:400,
                    head:'<div style="height:13px"></div>',
                    result:'<div class="tree" id="categoryTree"></div>',
                    resultWidth:94
                },
                panelEvent:function(panel){
                    categoryTree(panel);
                }
            },
            searchCommodity:{
                panelConf:{
                    top:42,
                    left:$.browser.msie?468:414,
                    width:250,
                    height:400,
                    head:'<div style="height:13px"></div>',
                    result:'<div class="inbox" id="commdityMenu"></div>',
                    resultWidth:94
                },
                panelEvent:function(panel){
                    commdityMenu(panel);
                }
            }
        }
        );
        bindClose();
        bindmysharePage();
    });
}


$(function(){
    //拼音索引
    var ABCIndex= function(panel){
        var currentIndex = null;
        var historySearchBrand = "";
        var $brandList = $("#brandList");
        var historySearch = null;
        var t = this;
        $("#abcIndex span").click(function(){
            var $thisindex = $(this);
            if(!currentIndex){
                $thisindex.addClass("on");
                currentIndex=$thisindex;
            }
            if(!historySearch){
                historySearch = new SearchHistory(t,panel);
            }
            var searchText = $thisindex.attr("index");
            historySearch.addHistory(searchText);
        });
        this.clearCurrentIndex = function(){
            if(currentIndex){
                currentIndex.removeClass("on");
                currentIndex = null;
                if(historySearch){
                    historySearch.clearHistory();
                }
            }
        }
    }

    //历史搜索
    var SearchHistory = function(parent,panel){
        var $searchHistory = $("#searchHistory");
        var historySearchBrand = "";
        var temp = this;
        $("#closeHistory").click(function(){
            parent.clearCurrentIndex();
        });
        this.addHistory = function(searchText){
            historySearchBrand += searchText;
            $searchHistory.css("display","block");
            $searchHistory.append("<span index=\""+historySearchBrand+"\"><a href=\"#\">"+historySearchBrand+"</a></span>");
            this.rollback();
            $lastchild =  $("#searchHistory span:last-child");
            $lastchild.click(function(){
                var index = $(this).attr("index");//获得历史点击的节点Index
                historySearchBrand=index;
                var currentHistory = $(this);
                currentHistory.nextAll().remove();
                currentHistory.addClass("on");
                BrandList.loadBrand(temp,historySearchBrand,panel);
            });
            $lastchild.click();
        }
        this.clearHistory = function(){
            $searchHistory.find("span").remove();
            $searchHistory.css("display","none");
            historySearchBrand="";
            BrandList.clearList(panel);
        }
        this.rollback = function(){
            $("#searchHistory span").removeClass("on");
            var $lastchild = $("#searchHistory span:last-child");
            $lastchild.addClass("on");
        }
    }


    //品牌列表
    var BrandList = {
        $brandlist:null,
        loadBrand:function(historyObj,index,panel){
            BrandList.$brandlist = BrandList.$brandlist==null ? $("#brandList"):BrandList.$brandlist;
            $("#brandList").load("brandList.html","",function(data){
                if(data=="null"){
                    historyObj.rollback();
                }
                $("#brandList span a").click(function(){
                    $("#brand_input").val($(this).text());
                    panel.close();
                });
            });
        },
        clearList:function(){
            if(BrandList.$brandlist)
                BrandList.$brandlist.empty();
        }
    }

    //品类树
    function categoryTree(panel){
        $("#categoryTree").empty();
        new Tree('[{id:"a",text:"1alskdfjalslaksdfadskf",childs:[{id:"a1",text:"sdfasdf"}]}]',"categoryTree");
        $("#categoryTree span").click(function(){
            $("#categoryInput").val($(this).text());
            panel.close();
        });
    }

    //品名菜单
    function commdityMenu(panel){
        $("#commdityMenu").empty();
        $("#commdityMenu").append('<ul class="menuitem"><li><a href="#">是大块发生地方块</a></li><li><a href="#">是大块发生地方块</a></li><li><a href="#">是大块发生地方块</a></li><li><a href="#">是大块发生地方块</a></li></ul>');
        $("#commdityMenu ul li a").click(function(){
            $("#commodityInput").val($(this).text());
            panel.close();
        });
    }




    $("#addquestion").click(function(){
		
        $("#dd1").show();
		
    });
	
    $("#questionPage span").click(function(){
        var $answerDiv = $("#answerDiv");
        $answerDiv.empty();
        $answerDiv.append('<div class="loading"></div>');
        $answerDiv.load("answer.html","");
    });
});
